<?php

//Rquire MySqlAdapter.
require_once(dirname(__FILE__).'/../db/MySqlAdapter.php');

class classDBHandler {

 	/*************************************************************************
	*************************      Public Methods     ************************
	*************************************************************************/
	
		//This function returns a table with student details 
		public static function find_class($class_name,$selected)
		{
			return classDBHandler::classDetails($class_name,$selected);
		}
	
	
	/*****************       Private Methods        *******************/

	private static function classDetails($class_name,$selected) {
		 $mysql_link = MySqlAdapter::get_mysql_link();
		 
		 $query = classDBHandler::class_details($class_name,$selected);
		 $result = mysql_query($query, $mysql_link);	//Excecute the Query
		 
		return $result;
	}
	
	/*************************************************************************
	*************************   Queires Methods   ****************************
	*************************************************************************/

	private static function class_details($class_name,$selected)	
	{
		 switch($selected){
			 case 0://class details
					$query=
					"SELECT *
					 FROM `ohel_shelomo_2012`.`classes` 
					 WHERE name= '".$class_name."'";
					break;
			case 1: //add new class
				$query=
				"INSERT INTO `ohel_shelomo_2012`.`classes` (`name`, `day`, `start_time`, `end_time`, `teacher`) VALUES ('".$class_name->name."', '".$class_name->day."', '".$class_name->start_time."', '".$class_name->end_time."', '".$class_name->teacher_name."')";
				break;
				
		 }

		return $query;
	}
	
	
}
?>